package com.capinfo.service.impl;

import com.capinfo.base.BaseEntity;
import com.capinfo.base.BaseMapper;
import com.capinfo.base.impl.BaseServiceImpl;
import com.capinfo.entity.CapService;
import com.capinfo.entity.CapServiceKind;
import com.capinfo.entity.CapServiceType;
import com.capinfo.mapper.CapServiceKindMapper;
import com.capinfo.mapper.CapServiceMapper;
import com.capinfo.service.CapServiceKindService;
import com.capinfo.service.CapServiceService;
import com.capinfo.util.JsonUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author: sunbenjin
 * @date: 2020/3/3
 **/
@Service
public class CapServiceKindServiceImpl extends BaseServiceImpl<CapServiceKind,String> implements CapServiceKindService {

    @Autowired
    CapServiceKindMapper capServiceKindMapper;
    @Override
    public BaseMapper<CapServiceKind, String> getMappser() {
        return capServiceKindMapper;
    }

    @Override
    public List<CapServiceKind> selectListByPage(CapServiceKind record) {
        return capServiceKindMapper.selectListByPage(record);
    }

    @Override
    public int insert(CapServiceKind capServiceKind) {
        capServiceKind = super.addValue(capServiceKind,false);
        return capServiceKindMapper.insert(capServiceKind);
    }

    @Override
    public CapServiceKind selectByPrimaryKey(Object o){
        return capServiceKindMapper.selectByPrimaryKey(o);
    }

    @Override
    public JsonUtil delById(String id, boolean flag) {
        JsonUtil j=new JsonUtil();

        try {
            CapServiceKind capServiceKind = selectByPrimaryKey(id);
            if (flag) {
                //逻辑
                capServiceKind.setDelFlag(BaseEntity.DEL_FLAG_DELETE);
                updateByPrimaryKeySelective(capServiceKind);
            } else {
                //物理
                capServiceKind.setDelFlag(BaseEntity.DEL_FLAG_DELETE);
                updateByPrimaryKeySelective(capServiceKind);
//                capServiceTypeMapper.delById(id);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        j.setMsg("删除成功");
        return j;
    }


}
